﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace mediatheque.Areas.Admin.Models
{
    public class Members : mediathequeEntities
    {
        public List<user> memberData;

        public List<user> getMembers()
        {
            var list = from u in users
                       orderby u.username ascending
                       select u;
            return list.ToList();
        }

        public List<user> getMemberById(int id)
        {
            var list = from u in users
                       where u.id == id
                       select u;
            this.memberData = list.ToList();
            return this.memberData;
        }

        public List<role> getRoles()
        {
            var list = from r in roles
                       orderby r.label
                       select r;
            return list.ToList();
        }

        public List<emprunts> getEmpruntHistory()
        {
            var list = (from emp in emprunts
                       where emp.back == true
                       orderby emp.date_emprunt
                       select emp).ToList();
            return list;
        }

        public List<emprunts> getEmpruntEnCours()
        {
            var list = (from emp in emprunts
                        where emp.back == null
                        orderby emp.date_emprunt
                        select emp).ToList();
            return list;
        }

        public List<movies> getMovieById(int id)
        {
            var movie = new Oeuvres();
            return movie.getMoviesById(id);
        }
    }
}